<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-04 16:53:56
 * @LastEditTime: 2023-10-05 14:55:13
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description: 
 */

namespace App\Http\Services\Pro;


use App\Http\Services\Service;
use App\Repositories\ProRepairreasonRepository;
use App\Repositories\ProRepairreasonDetailsRepository;

/**
 * @property ProRepairreasonRepository $repository
 * @property ProRepairreasonDetailsRepository $details 
 */
class RepairreasonService extends Service
    {
    public function boot(
        ProRepairreasonRepository $repository,
        ProRepairreasonDetailsRepository $details,
    ) {
        $this->repository = $repository;
        $this->details    = $details;
        }

    public function list()
        {
        // DB::enableQueryLog();
        $data = $this->repository->condition(request())->getGrid();
        // dd(DB::getQueryLog());

        return $data;
        }


    protected function save()
        {
        $data = request()->toArray();

        return $this->repository->autosave($data);
        }

    protected function audit()
        {
        return $this->repository->whereIn("id", $this->getRequestIds())->get()->filter(function ($v)
            {
            enable($v);
            });
        }

    protected function noaudit()
        {
        return $this->repository->whereIn("id", $this->getRequestIds())->get()->filter(function ($v)
            {
            enable($v, false);
            });
        }

    }